package study.cell_game.objects.tokens;

import study.cell_game.enums.TokenType;

public class ProcesorLogic implements TokenLogic {

	private TokenType type;
	private Token parent;
	
	public ProcesorLogic(TokenType type){
		this.type = type;
	}
	
	@Override
	public void update() {
	 int cg = parent.getCharges();
	 
	 cg += generateCharges();
	 parent.setCharges(cg);
		
	}

	@Override
	public boolean isStackAllowed(TokenType type) {
		return (this.type == TokenType.PROC2 || this.type == TokenType.PROC1) && type == TokenType.PROC1;
	}

	@Override
	public boolean hasOwner() {
		return parent.getOwner() != null;
	}
	
	private int generateCharges()
	{
		return type.getValue();
	}


	@Override
	public Token getParent() {
		return parent;
	}

	@Override
	public void setParent(Token parent) {
		this.parent = parent;
	}

}
